
// Copyright (C) Recursion Company. All rights reserved.

#ifndef __VOL_MFC_RICH_EDIT_H__
#define __VOL_MFC_RICH_EDIT_H__

class IRichEditEventListener : public IBaseEventListener
{
public:
    virtual void OnChange () = 0;
    virtual void OnSelChange () = 0;
};

class CVWnd_RichEdit : public CRichEditCtrl
{
    DECLARE_VOL_NATIVE_WND_CLASS (CVWnd_RichEdit, CRichEditCtrl, IRichEditEventListener, TRUE)
    
    inline_ ~CVWnd_RichEdit ()
    {
        if (m_hInstRichEdit != NULL)
            ::FreeLibrary (m_hInstRichEdit);
    }

protected:
    //{{AFX_MSG(CVWnd_RichEdit)
	afx_msg void OnChange();
	afx_msg void OnKillfocus();
	afx_msg void OnSetfocus();
    afx_msg void OnProtected(NMHDR* pNMHDR, LRESULT* pResult);
    afx_msg void OnSelChange(NMHDR* pNMHDR, LRESULT* pResult);
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP ()

public:
    void SetContent (const TCHAR* szContent, BOOL blOnlySelection);
    void GetContent (CVolString& strContent, BOOL blOnlySelection);
    void SetRichEditSel (INT nSelStart, INT nSelLength);
	inline_ void LimitRichEditText (INT nChars)
    {
	    LimitText (nChars <= 0 ? INT_MAX : nChars);
    }

public:
    BOOL m_blPlainTextMode;
    INT m_nContentType;
    INT m_nBorderType;
    COLORREF m_clrBackColor;
    BOOL m_blMutiLine;
    BOOL m_blAutoNextLine;
    BOOL m_blReadOnly;
    BOOL m_blHideSelection;
    INT m_nMaxAllowLength;
    INT m_nSelStart;
    INT m_nSelLength;

protected:
    BOOL m_blModifingProperty;
    HINSTANCE m_hInstRichEdit;
};

#endif
